package com.hongyue.Dey07;

import java.io.*;
import java.util.ArrayList;

public class Demo {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        ArrayList<Student> list = new ArrayList<>();
        list.add(new Student("迪丽热巴","女","18","99"));
        list.add(new Student("古力娜扎","女","19","98"));
        list.add(new Student("周杰伦","男","20","88"));
        list.add(new Student("蔡徐坤","男","19","78"));
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("dey13\\src\\com\\hongyue\\dey07\\aaa.txt"));
        oos.writeObject(list);
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("dey13\\src\\com\\hongyue\\dey07\\aaa.txt"));
        ArrayList arr = (ArrayList) ois.readObject();
        for (Object o : arr) {
            System.out.println(o);
        }
        ois.close();
        oos.close();
    }
}
